package com.transcargo.rpc;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

public class RPCOutput {
	public static String generate(Object obj)
	{
		XStream xstream = new XStream(new DomDriver("UTF-8"));
		String xml = xstream.toXML(obj);


		String res = "<RPCReply>";
		res = res + xml;
		res = res + "</RPCReply>";
		return res;
	}
	public static String generate(Object obj1, Object obj2)
	{
		XStream xstream = new XStream(new DomDriver("UTF-8"));
		String xml1 = xstream.toXML(obj1);
		String xml2 = xstream.toXML(obj2);


		String res = "<RPCReply>";
		res = res + xml1 + xml2;
		res = res + "</RPCReply>";
		return res;
	}
	public static String generate(Object obj, String cookieName, String cookieValue)
	{
		XStream xstream = new XStream(new DomDriver("UTF-8"));
		String xml = xstream.toXML(obj);


		String res = "<RPCReply " + cookieName + "=\"" + cookieValue + "\">";
		res = res + xml + "\n";
		res = res + "</RPCReply>\n";
		return res;
	}
    public static String generate(Object obj, String cookieName, String cookieValue, int count, int page, int page_elements)
    {
        XStream xstream = new XStream(new DomDriver("UTF-8"));
        String xml = xstream.toXML(obj);


        String res = "<RPCReply " + cookieName + "=\"" + cookieValue + "\" count=\"" + count + "\" page=\"" + page + "\" elements=\"" + page_elements + "\">";
        res = res + xml + "\n";
        res = res + "</RPCReply>\n";
        return res;
    }

}
